<?
$this->headScript()->offsetSetFile(91,$this->baseUrl('js/AquaGauge.js'),'text/javascript');

?>

<style type="text/css"  media="screen,print">

/* tables */

.jTipImg{display:inline;cursor:pointer;color:#990000}

.mitabla {
	font-family:arial;
	margin:10px 0px 15px;
	font-size: 1em;
	width: 100%;
	text-align: center;
	border:2px;
	border-collapse: collapse;
}

.mitabla td {
	margin:2px;
	padding-top:3px;
	padding-bottom:3px;
	
	border-style:solid;
	border-width:1px;
	border-color:#C1C1C1;
}


.mitable_head {
	background-color: #E9E9E9;
	font-weight: bold;
	text-align: left;
}
.derechos  {
	background-color: #FFFFFF;
}
.col_2 {
	background-color: #E9E9E9;
}

.n {
	font-weight: bold;
}

.green {
	background-color: #00FF00;


}
.yellow {
	background-color: #FFAA00;
	font-weight: bold;

}

#amarillo {
	background-color: #FFAA00;
	width:50px;
	height:25px;
	border-radius:10px;
	-moz-border-radius:10px;
}
#verde {
	background-color: #00FF00;
	width:50px;
	height:25px;
	border-radius:10px;
	-moz-border-radius:10px;
}
.center { margin:0 auto 0 auto; width:390px; }

td {
	border-width:0px;
	border-color:#FFFFFF;
}

input.objetivo{
 	border: 0px;
	padding: 0px;
	font-size: 1em;
	background-color: transparent;
    width:29px;
}
input.objetivo:hover{
  	border: 1px solid #888888;
	padding: 0px;
	font-size: 1em;
	background-color: #FFFE9D;
	-moz-border-radius:5px;
	border-radius:5px;

}
.lupa{
    float:right;
}


.rotate1{
    color: #444444;
    font-size: 1.8em;
    text-align: center;
}
.rotate2{
    color: #666666;
    font-size: 1.3em;
    text-align: center;
}
.rotate3{
    color: #888888;
    font-size: 1em;
    text-align: center;
}


tr.m3 td{
    background-color: #FCDFCD;
    color: #888888;
    font-size: 1em;
    font-weight: bold;
    text-align: center;
}


</style>
<?php $this->placeholder('onReady')->captureStart() ?>

<?

foreach(array('derechos','contratado','cte','ups','grupos','clima') as $clave){
    foreach($this->datos[$clave] as $z => $val)
    {
        $valor=0;
        foreach($val as $key => $value)
        {
            if(isset($value) && $key > 0){
                if($valor < $value['uso']){
                    $valor=$value['uso'];
                }
            }
        }
        if($valor > 0)
        {
            $color=$this->cmcolor($z);
               print "gauge = new AquaGauge('$clave-$z');\n";
               print "gauge.refresh($valor,'test','$valor','$color');\n";
        }
    }
};

?>


$("select").change(function () {
    location.href="/cuadro-mando-semanal/index/fecha/"+this.value
})


$(".objetivo").change(function () {
        var valor = $('#'+this.id).val();
        valor=valor.split(',').join('.')
        $('#'+this.id).next().hide()
        $.post('/cuadro-mando-semanal/editar',{valor:valor,nombre:this.id }, function(data){
            if(data.status=='ok')
            {
                $('#'+data.id).after('<img src="/img/agt_action_success.png"/>')
    		}else{
                $('#'+data.id).after('<img src="/img/cancel.png"/>')
    		}
            
        });
})



<?php $this->placeholder('onReady')->captureEnd() ?>


<?=$this->fechas_lecturas?>


<table width="100%" border="0">
    <tr>
        <td rowspan="2">
            <div class="ui-widget-header ui-corner-all" style="font-size: 2em;margin-bottom:5px;padding:4px">Semana <?=$this->datos['semana']?>|  <?=$this->dateTo($this->datos['fecha'],'EEEE, dd MMMM yyyy')?></div>
        </td>
        <td><small>Valores Máximos Semanales</small></td>
        <td width="30px">
            <div id="amarillo">
        </td>
        <td>
            <small>Superado umbral de preaviso. Activar proyecto de aumento de capacidad.</small>
        </td>
    <tr>
        <td>
            <small>Todos los valores de capacidad y ocupación en kW</small>
        </td>
        <td width="30px">
            <div id="verde"></div>
        </td>
        <td>
            <small>Situación normal.</small>
        </td>
    </tr>
</table>



<table class="mitabla">

<tr class="n ui-widget-header">
    <td class="ui-widget-header" colspan="2" rowspan="1"><div class="rotate1">Compañia Eléctrica</div></td>
    
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="ui-widget-header"><div class="rotate1"><?=$this->zona($z)?></div></td>
    <?endforeach?>
    <td valign="top" class="ui-widget-header"><div class="rotate1">Global</div></td>
    
</tr>

<tr class="n">
    <td class="col_2" colspan="2" rowspan="1">&nbsp;</td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>" width="55px">Capacidad</td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>" width="55px">Ocupación</td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>" width="55px">% Ocup</td>
    <?endforeach?>
    <td valign="top" width="55px">Ocupación</td>
</tr>

<tr>
    <td valign="middle" rowspan="4" class="mitable_head" width="120px">
    <div class="rotate2"><br><br>Derechos <br><br>de<br><br> extensión</div>
    </td>
    <td valign="top" class="mitable_head" width="90px"><div class="rotate3">Acometida 1</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['derechos'][$z][1]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['derechos'][$z][1]['id_contador'],$this->fecha,$this->numEs($this->datos['derechos'][$z][1]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['derechos'][$z][1])?>"><?=$this->numEs($this->datos['derechos'][$z][1]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>

<tr>
    <td valign="middle" class="mitable_head"><div class="rotate3">Acometida 2</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['derechos'][$z][2]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['derechos'][$z][2]['id_contador'],$this->fecha,$this->numEs($this->datos['derechos'][$z][2]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['derechos'][$z][2])?>"><?=$this->numEs($this->datos['derechos'][$z][2]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>
<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">Total</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['derechos'][$z][0]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['derechos'][$z][0]['potencia'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['derechos'][$z][0]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"><?=$this->numEs($this->datos['derechos']['global']['potencia'],0)?></td>
    
</tr>
<tr>
    <td valign="top" class="mitable_head"></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>" colspan="3"><canvas id="derechos-<?=$z?>" width="90" height="90"></canvas></td>
    <?endforeach?>	
    <td valign="top"></td>
    </tr>
    <tr>
    <td valign="middle" rowspan="4" class="mitable_head">
    <div class="rotate2"><br><br>Potencia <br><br><br><br> Contratada</div>
    </td>
    <td valign="top" class="mitable_head"><div class="rotate3">Acometida 1</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['contratado'][$z][1]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['contratado'][$z][1]['id_contador'],$this->fecha,$this->numEs($this->datos['contratado'][$z][1]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['contratado'][$z][1])?>"><?=$this->numEs($this->datos['contratado'][$z][1]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>

<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">Acometida 2</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['contratado'][$z][2]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['contratado'][$z][2]['id_contador'],$this->fecha,$this->numEs($this->datos['contratado'][$z][2]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['contratado'][$z][2])?>"><?=$this->numEs($this->datos['contratado'][$z][2]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>
<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">Total</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['contratado'][$z][0]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['contratado'][$z][0]['potencia'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['contratado'][$z][0]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"><?=$this->numEs($this->datos['contratado']['global']['potencia'],0)?></td>
    
</tr>
<tr>
    <td class="mitable_head" colspan="1"></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>" colspan="3"><canvas id="contratado-<?=$z?>" width="90" height="90"></canvas></div></td>
    <?endforeach?>	
    <td valign="top"></td>
</tr>


<tr class="n ui-widget-header">
    <td class="ui-widget-header" colspan="2" rowspan="1"><div class="rotate1">Suministro Eléctrico</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="ui-widget-header <?=$this->validado[$z]?>"><div class="rotate1"><?=$this->zona($z)?></div></td>
    <?endforeach?>
    
    <td valign="top" class="ui-widget-header"><div class="rotate1">Global</div></td>
</tr>


<tr>
    <td valign="top" rowspan="9" class="mitable_head"><div class="rotate2"><br><br><br><br>Red<br> <br>normal</div></td>
    <td valign="top" class="mitable_head"><div class="rotate3">Tipo de redundancia</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>" colspan="3" align="left"><small><?=$this->datos['cte'][$z]['redundancia']?></small></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>
<tr>

<td valign="top" class="mitable_head"><div class="rotate3">CTE-1</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['cte'][$z][1]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['cte'][$z][1]['id_contador'],$this->fecha,$this->numEs($this->datos['cte'][$z][1]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['cte'][$z][1])?>"><?=$this->numEs($this->datos['cte'][$z][1]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>
<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">CTE-2</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['cte'][$z][2]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['cte'][$z][2]['id_contador'],$this->fecha,$this->numEs($this->datos['cte'][$z][2]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['cte'][$z][2])?>"><?=$this->numEs($this->datos['cte'][$z][2]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>
<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">CTE-3.1</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['cte'][$z][3]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['cte'][$z][3]['id_contador'],$this->fecha,$this->numEs($this->datos['cte'][$z][3]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['cte'][$z][3])?>"><?=$this->numEs($this->datos['cte'][$z][3]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>

<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">CTE-3.2</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['cte'][$z][4]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['cte'][$z][4]['id_contador'],$this->fecha,$this->numEs($this->datos['cte'][$z][4]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['cte'][$z][4])?>"><?=$this->numEs($this->datos['cte'][$z][4]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>
<tr class="m3">
    <td valign="top" class="mitable_head"><div class="rotate3">CTE-4 (M3)</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['cte'][$z][5]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['cte'][$z][5]['id_contador'],$this->fecha,$this->numEs($this->datos['cte'][$z][5]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['cte'][$z][3])?>"><?=$this->numEs($this->datos['cte'][$z][5]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>

<tr class="m3">
    <td valign="top" class="mitable_head"><div class="rotate3">CTE-5 (M3)</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['cte'][$z][6]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['cte'][$z][6]['id_contador'],$this->fecha,$this->numEs($this->datos['cte'][$z][6]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['cte'][$z][6])?>"><?=$this->numEs($this->datos['cte'][$z][6]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>



<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">Total</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['cte'][$z][0]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link2,6,$this->fecha,$z,$this->numEs($this->datos['cte'][$z][0]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['cte'][$z][0]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top" ><?=$this->numEs($this->datos['cte']['global']['potencia'],0)?></td>
</tr>

<tr>
    <td class="mitable_head" colspan="1"></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>" colspan="3"><canvas id="cte-<?=$z?>" width="90" height="90"></canvas></div></td>
    <?endforeach?>	
    <td valign="top"></td>
</tr>



<tr>
    <td valign="top" rowspan="7" class="mitable_head"><div class="rotate2"><br><br><br><br><br><br>UPS<br><br>Clientes</div></td>
    <td valign="top" class="mitable_head"><div class="rotate3">Tipo de redundancia</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>" colspan="3" align="left"><small><?=$this->datos['ups'][$z]['redundancia']?></small></td>
    <?endforeach?>

</tr>
<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">CC1+CC2 <small> <br />(CC1+CC6 en M2)</div></small></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['ups'][$z][1]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['ups'][$z][1]['id_contador'],$this->fecha,$this->numEs($this->datos['ups'][$z][1]['potencia'],0))?><?=sprintf($this->link7,$z,$this->fecha)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['ups'][$z][1])?>"><?=$this->numEs($this->datos['ups'][$z][1]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>
<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">CC3+CC4 <small> <br />(CC2+CC4 en M2)</small></div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['ups'][$z][2]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['ups'][$z][2]['id_contador'],$this->fecha,$this->numEs($this->datos['ups'][$z][2]['potencia'],0))?><?=sprintf($this->link7,$z,$this->fecha)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['ups'][$z][2])?>"><?=$this->numEs($this->datos['ups'][$z][2]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>
<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">CC5+CC6 <small> <br />(CC3+CC5 en M2)</small></div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['ups'][$z][3]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['ups'][$z][3]['id_contador'],$this->fecha,$this->numEs($this->datos['ups'][$z][3]['potencia'],0))?><?=sprintf($this->link7,$z,$this->fecha)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['ups'][$z][3])?>"><?=$this->numEs($this->datos['ups'][$z][3]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>
<tr class="m3">
    <td valign="top" class="mitable_head"><div class="rotate3">CC7+CC8 (M3)<small> </small></div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['ups'][$z][4]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['ups'][$z][4]['id_contador'],$this->fecha,$this->numEs($this->datos['ups'][$z][4]['potencia'],0))?><?=sprintf($this->link7,$z,$this->fecha)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['ups'][$z][4])?>"><?=$this->numEs($this->datos['ups'][$z][4]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>

<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">Total</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['ups'][$z][0]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link2,9,$this->fecha,$z,$this->numEs($this->datos['ups'][$z][0]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['ups'][$z][0]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top" ><?=$this->numEs($this->datos['ups']['global']['potencia'],0)?></td>
</tr>
<tr>
    <td class="mitable_head" colspan="1"></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>" colspan="3"><canvas id="ups-<?=$z?>" width="90" height="90"></canvas></div></td>
    <?endforeach?>	
    <td valign="top"></td>
</tr>

<tr>
    <td valign="top" class="mitable_head" colspan="2"><div class="rotate2">Rectificadores Clientes</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['dc'][$z][1]['id_contador'],$this->fecha,$this->numEs($this->datos['dc'][$z][1]['potencia'],0))?></td>
    <?endforeach?>
    <td valign="top" ><?=$this->numEs($this->datos['dc']['global']['potencia'],0)?></td>
</tr>

<tr>
    <td valign="top" class="mitable_head" colspan="2"><div class="rotate2">Red Normal Clientes</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['rs'][$z][1]['id_contador'],$this->fecha,$this->numEs($this->datos['rs'][$z][1]['potencia'],0))?></td>
    <?endforeach?>
    <td valign="top" ><?=$this->numEs($this->datos['rs']['global']['potencia'],0)?></td>
</tr>


<tr>
    <td valign="top" class="mitable_head" colspan="2"><div class="rotate2">Total Clientes</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link2,999,$this->fecha,$z,$this->numEs($this->datos['total_cliente'][$z][1]['potencia'],0))?></td>
    <?endforeach?>
    <td valign="top" ><?=$this->numEs($this->datos['total_cliente']['global']['potencia'],0)?></td>
</tr>

<tr class="n ui-widget-header">
    <td class="ui-widget-header" colspan="2" rowspan="1"><div class="rotate1">Suministro</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="ui-widget-header <?=$this->validado[$z]?>"><div class="rotate1"><?=$this->zona($z)?></div></td>
    <?endforeach?>
    <td valign="top" colspan="3" class="ui-widget-header"><div class="rotate1">Global</div></td>
</tr>

<tr>
    <td valign="top" rowspan="5" class="mitable_head"><div class="rotate2"><br><br><br>Grupos <br><br>Electrógenos</div></td>
    <td valign="top" class="mitable_head"><div class="rotate3">Tipo de redundancia</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>" colspan="3" align="left"><small><?=$this->datos['grupos'][$z]['redundancia']?></small></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>

<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">Sistema 1</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['grupos'][$z][1]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['grupos'][$z][1]['id_contador'],$this->fecha,$this->numEs($this->datos['grupos'][$z][1]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['grupos'][$z][1])?>"><?=$this->numEs($this->datos['grupos'][$z][1]['uso'])?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>

<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">Sistema 2</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['grupos'][$z][2]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['grupos'][$z][2]['id_contador'],$this->fecha,$this->numEs($this->datos['grupos'][$z][2]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['grupos'][$z][2])?>"><?=$this->numEs($this->datos['grupos'][$z][2]['uso'])?></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>
<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">Total</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['grupos'][$z][0]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['grupos'][$z][0]['potencia'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['grupos'][$z][0]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top" ><?=$this->numEs($this->datos['grupos']['global']['potencia'],0)?></td>
</tr>
<tr>
    <td class="mitable_head" colspan="1"></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>" colspan="3"><canvas id="grupos-<?=$z?>" width="90" height="90"></canvas></div></td>
    <?endforeach?>	
    <td valign="top"></td>
</tr>

<tr>
    <td valign="top" rowspan="5" class="mitable_head"><div class="rotate2"><br><br><br>Climatización</div></td>
    <td valign="top" class="mitable_head"><div class="rotate3">Tipo de redundancia</div></td>
        <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>" colspan="3" align="left"><small><?=$this->datos['clima'][$z]['redundancia']?></small></td>
    <?endforeach?>
    <td valign="top"></td>
</tr>

<tr>
<td valign="top" class="mitable_head"><div class="rotate3">Clima</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['clima'][$z][1]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['clima'][$z][1]['id_contador'],$this->fecha,$this->numEs($this->datos['clima'][$z][1]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['clima'][$z][1])?>"><?=$this->numEs($this->datos['clima'][$z][1]['uso'])?></td>
    <?endforeach?>
    <td valign="top" ></td>
</tr>
<tr class="m3">
<td valign="top" class="mitable_head"><div class="rotate3">Clima (M3)</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['clima'][$z][2]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['clima'][$z][2]['id_contador'],$this->fecha,$this->numEs($this->datos['clima'][$z][2]['potencia'],0))?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?=$this->cmumbral($this->datos['clima'][$z][2])?>"><?=$this->numEs($this->datos['clima'][$z][2]['uso'])?></td>
    <?endforeach?>
    <td valign="top" ></td>
</tr>
<tr>
    <td valign="top" class="mitable_head"><div class="rotate3">Total</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['clima'][$z][0]['potencia_instalada'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['clima'][$z][0]['potencia'],0)?></td>
    <td valign="top" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->numEs($this->datos['clima'][$z][0]['uso'],2)?></td>
    <?endforeach?>
    <td valign="top" ><?=$this->numEs($this->datos['clima']['global']['potencia'],0)?></td>
</tr>

<tr>
    <td class="mitable_head" colspan="1"></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>" colspan="3"><canvas id="clima-<?=$z?>" width="90" height="90"></canvas></div></td>
    <?endforeach?>	
    <td valign="top"></td>
</tr>


<tr>
    <td valign="top" colspan="2" class="mitable_head"><div class="rotate2">Oficinas</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link1,$this->datos['oficinas'][$z][1]['id_contador'],$this->fecha,$this->numEs($this->datos['oficinas'][$z][1]['potencia'],0))?></td>
    <?endforeach?>
    <td valign="top" ><?=$this->numEs($this->datos['oficinas']['global']['potencia'],0)?></td>
</tr>

<tr class="n ui-widget-header">
    <td class="ui-widget-header" colspan="2" rowspan="1"><div class="rotate1">PUE</div></td>
    
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="ui-widget-header <?=$this->validado[$z]?>"><div class="rotate1"><?=$this->zona($z)?></div></td>
    <?endforeach?>
    <td valign="top" class="ui-widget-header"><div class="rotate1">Global</div></td>
</tr>
<tr>
    <td valign="top" colspan="2" class="mitable_head"><div class="rotate2">Semana Actual</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link4,$z,$this->fecha,$this->numEs($this->datos['pue'][$z][1]['pue'],4))?></td>
    <?endforeach?>
    <td valign="top" class="mitable_head"><div class="rotate3" style="float:right"></div><?=sprintf($this->link4,$this->key_zonas,$this->fecha,$this->numEs($this->datos['pue_global']['pue'],4))?></td>
    
 </tr>

<tr>
    <td valign="top" colspan="2" class="mitable_head"><div class="rotate2">Semana Anterior</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link4,$z,$this->datos['fecha_anterior'],$this->numEs($this->datos['pue'][$z][1]['pue_anterior'],4))?></td>
    <?endforeach?>
    <td valign="top" class="mitable_head"><div class="rotate3" style="float:right"></div><?=sprintf($this->link4,$this->key_zonas,$this->datos['fecha_anterior'],$this->numEs($this->datos['pue_global_anterior']['pue'],4))?></td>
    
  </tr>

<tr>
    <td valign="top" colspan="2" class="mitable_head"><div class="rotate2">Mensual <?=$this->mes_mensual?></div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=sprintf($this->link5,$z,$this->fecha,$this->numEs($this->datos['pue_mensual'][$z]['pue'],4))?></td>
    <?endforeach?>
    <td valign="top" class="mitable_head"><div class="rotate3" style="float:right"></div><?=sprintf($this->link5,$this->key_zonas,$this->fecha,$this->numEs($this->datos['pue_mensual']['global']['pue'],4))?></td>
 </tr>

<tr>
    <td valign="top" colspan="2" class="mitable_head"><div class="rotate2">YTD <?=$anio?></div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?> <?if($this->datos['objetivos'][$z] && !$this->key_zonas):if($this->datos['pue_plan'][$z] <= $this->datos['pue'][$z][1]['pue_acumulado']):?> yellow <?else:?>green<?endif;endif;?>"><?=sprintf($this->link6,$z,$this->fecha,$this->numEs($this->datos['pue'][$z][1]['pue_acumulado'],4))?></td>
    <?endforeach?>
    <td valign="top" class="mitable_head <?if($this->datos['objetivos']['global'] && !$this->key_zonas): if($this->datos['pue_plan']['global'] <= $this->datos['pue_global']['pue_acumulado']):?> yellow <?else:?>green <?endif;endif?>"></div><?=sprintf($this->link6,$this->key_zonas,$this->fecha,$this->numEs($this->datos['pue_global']['pue_acumulado'],4))?></td>
    
</tr>
<?if(!$this->key_zonas):?>
<tr>
    <td valign="top" colspan="2" class="mitable_head"><div class="rotate2">Objetivo YTD</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><?=$this->NumEs($this->datos['pue_plan'][$z],4)?></td>
    <?endforeach?>
    <td valign="top" class="mitable_head"><?=$this->NumEs($this->datos['pue_plan']['global'],4)?> </td>
</tr>
<tr>
    <td valign="top" colspan="2" class="mitable_head"><div class="rotate2">Objetivo Fin Año</div></td>
    <?foreach($this->datos['zonas'] as $z):?>
    <td valign="top" colspan="3" class="<?=$this->cmcolor($z,1)?> <?=$this->validado[$z]?>"><input type="text" id="objetivo_<?=$z?>_<?=$this->dateTo($this->fecha,'yyyy');?>" value="<?=$this->datos['objetivos'][$z]?>" class="objetivo" /></td>
    <?endforeach?>
    <td valign="top" class="mitable_head"><div class="rotate3" style="float:right"></div> <input type="text" id="objetivo_<?=$this->dateTo($this->fecha,'yyyy');?>" value="<?=$this->datos['objetivos']['global']?>" class="objetivo"/></td>
</tr>
<?endif?>
</table>
